#这个程序，指定了url就可以获取标题，网页代码等
import urllib.request
from bs4 import BeautifulSoup

# 要爬取的网页URL
url = "http://www.example.com"

# 打开URL，并读取网页内容
with urllib.request.urlopen(url) as response:
    html = response.read()

# 使用BeautifulSoup解析HTML代码
soup = BeautifulSoup(html, "html.parser")

# 获取网页标题
title = soup.find("title")

# 打印网页URL和标题
print("URL:", url)
print("Title:", title.string)
print("HTML:", html)